    {include file="head_2" title="用户列表" /}
    <div class="page-wrap">
        <div class="layui-fluid">
        <div class="layui-card">
            <div class="layui-card-body" style="padding: 15px;">
                <div class="page_menu"><a href="/admin/users/dladd.html" ><button class="layui-btn layui-btn-primary">添加</button></a></div>
                <div style="clear:both"></div>

                <table id='Goods' class="layui-hide" lay-filter="demo"></table>

            </div>
        </div>
    </div>
    <script type="text/html" id="barDemo">
        <a class="layui-btn layui-btn-mini" lay-event="edit">编辑</a>
        <a class="layui-btn layui-btn-danger layui-btn-mini" lay-event="del">删除</a>
    </script>
    </div>


    <script src="{$Think.const.admin_tpl}/layui/layui.js"></script>
    <!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
    <script>
        layui.use(['layer', 'table', 'jquery'], function () {
            var layer = layui.layer //弹层
                    , table = layui.table //表格
                    , $ = layui.$;
                    
        var heig = document.documentElement.clientHeight * 0.8;
        
        //方法级渲染
        table.render({
            elem: '#Goods'
            , url: '/admin/users/getdl_josn/'
            , cols: [[
                    {field: 'id', align: 'center', title: '编号', width: 80, sort: true, }
                    , {field: 'area', align: 'center', title: '代理区域', width: 300}
                    , {field: 'user', align: 'center', title: '账号', width: 200}
                    , {field: 'name', align: 'center', title: '姓名', width: 200}
                    , {field: 'last_time', align: 'center', title: '最后登录时间', width: 200}
                    , {field: 'last_ip', align: 'center', title: '最后登录IP', width: 200, }
                    , {fixed: 'right', align: 'center', width: 160, align: 'center', toolbar: '#barDemo', title: '操作'}
                ]]
            , id: 'Reload'
            , page: true
            , height: heig
        });

            //监听工具条
            table.on('tool(demo)', function (obj) {
                var data = obj.data
                        , layEvent = obj.event;
                if (layEvent === 'del') {
                    layer.confirm('真的删除行么', function (index) {
                        del_data(obj);
                        layer.close(index);
                        //向服务端发送删除指令
                    });
                } else if (layEvent === 'edit') {
                    location.href = "/admin/users/dledit/id/" + data.id;
                }
            });
            function del_data(obj)
            {
                var data = obj.data;
                $.ajax({
                    url: "/admin/users/del_submit/",
                    type: 'post',
                    data: {id: data.id},
                    dataType: 'json',
                    success: function (data) {
                        if (data.code == 1)
                        {
                            layer.msg("删除成功!", {
                                time: 2000
                            }, function () {
                                location.reload();
                            });
                        } else
                        {
                            layer.msg(data.msg);
                        }
                    },
                });
            }

        });
    </script>
    </body>
</html>